package testJdk.commonUse.collections.set;

import org.junit.Test;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;

/**
 * @version 1.0.0
 * Created by cyd on 2022-08-19 11:00:47
 * @ClassName : learn_jdk.commonUse.collections.set.TestSet
 * @Description : 类描述
 */
public class TestSet {

    /**
     * set增加元素
     */
    @Test
    public void test01() {
        HashSet<Long> set = new HashSet<>();
        set.add(1L);
        set.add(2L);
        System.out.println(set);
    }

    /**
     * 将list转化为set
     */
    @Test
    public void test02() {

        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);

        Set<Integer> set = new HashSet<>(list);
        System.out.println(set);

    }
}
